﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title> 
    <link href="../../../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
     <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>  
    <script src="../../../Comm/Gener.js" type="text/javascript" ></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script  type="text/javascript">

        var nodeID = 0;
        var fk_flow = "";
        $(function () {

            InitBar(FormType.FoolTruck);

            Sln(); //设置权限控制方案.

        });

        //权限控制方案.
        function Sln() {

            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            if (node.FormType != FormType.FoolTruck)
                return;

            var html = "<ul>";
            var nodes = new Entities("BP.WF.Nodes");
            nodes.Retrieve("FK_Flow", node.FK_Flow, "NodeID");

            var frmID = "ND" + GetQueryString("FK_Node");

            for (var i = 0; i < nodes.length; i++) {

                var json = nodes[i];
                if (json.NodeID == nodeID)
                    continue;

                var sln = new Entity("BP.WF.Template.FoolTruckNodeFrm");
                sln.MyPK = frmID + "_" + json.NodeID + "_" + json.FK_Flow;

                if (sln.IsExits() == false) {
                    sln.FK_Flow = json.FK_Flow;
                    sln.FK_Frm = frmID;
                    sln.FK_Node = json.NodeID; //节点ID.
                    sln.FrmSln = 1; //只读方案.
                    sln.Insert();                     
                } else {
                    sln.Retrieve();
                }

                if (sln.FrmSln == 1 || sln.FrmSln == 0) {
                    html += "<li>[只读]<a href=\"javascript:EditSln('" + sln.MyPK + "')\">" +json.NodeID+" - " + json.Name + "</a></li>";
                    continue;
                }

                var def = "";

                //def = " - <a href=\"javascript:DefField('')\" >定义字段权限</a>";
                def += " - <a href=\"javascript:DefAth('" + json.NodeID + "')\" >附件权限</a>";
                //def += " - <a href=\"javascript:DefDtl('')\" >从表权限</a>";

                html += "<li>[" + sln.FrmSlnText + "]<a href=\"javascript:EditSln('" + sln.MyPK + "')\">" + json.NodeID + " - " + json.Name + "</a> " + def + "</li>";
            }


            html += "</ul>";

            $("#sln").html(html);
        }
        function DefField() {
            alert('未开通.');
        }
        function DefDtl() {
            alert('未开通.');
        }
        function DefAth(nodeID) {

            var frmID = "ND" + GetQueryString("FK_Node");

            var aths = new Entities("BP.Sys.FrmAttachments");
            aths.Retrieve("FK_MapData", frmID);

            if (aths.length == 0) {
                alert('当前节点表单没有附件。');
                return;
            }
            if (aths.length != 1) {
                alert("未涉及到两个附件的情况.");
                return;
            }

            var ath = aths[0];
            var athSln = new Entity("BP.Sys.FrmAttachment");
            athSln.MyPK = nodeID + "_" + ath.NoOfObj;
            if (athSln.IsExits() == false) {

                athSln.CopyJSON(ath);
                athSln.MyPK = nodeID + "_" + ath.NoOfObj;
                athSln.FK_MapData = nodeID;
                athSln.CtrlWay = 4;
                athSln.Insert(); //插入新的.
            }

            var url = "../../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.FrmAttachmentExt&MyPK=" + athSln.MyPK;
            OpenEasyUiDialog(url, "eudlgframe", '附件权限', 600, 500, "icon-property", true, null, null, null, function () {
               // window.location.href = window.location.href;
            });

        }
        function EditSln(mypk) {

            var url = "../../../Comm/EnOnly.htm?EnName=BP.WF.Template.FoolTruckNodeFrm&MyPK=" + mypk;

            OpenEasyUiDialog(url, "eudlgframe", '表单方案', 600,300, "icon-property", true, null, null, null, function () {
                    window.location.href = window.location.href;
            });
        }

        function Save() {

            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            node.FormType = FormType.FoolTruck;
            node.NodeFrmID = "ND" + nodeID;
            node.Update();

            //更新表单类型.
            var frmID = "ND" + nodeID;
            var mapData = new Entity("BP.Sys.MapData", frmID);
            mapData.FrmType = FormType.FoolTruck;
            mapData.Update();
            
            //执行流程检查.
            var flow = new Entity("BP.WF.Flow", node.FK_Flow);
            flow.DoMethodReturnString("DoCheck"); 

            alert("保存成功.");
        }       
        

        ///设置该流程的所有节点都是用该方案。
        function SetAllNodeFrmUseThisSln() {

            if (confirm('您确定要设置吗？') == false)
                return;

            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);

            var flowNo = node.FK_Flow;
            var nds = new Entities("BP.WF.Nodes");
            nds.Retrieve("FK_Flow", flowNo);

            for (var i = 0; i < nds.length; i++) {

                var jsNode = nds[i];

                var node = new Entity("BP.WF.Node", jsNode);

                node.FormType = FormType.FoolTruck;
                node.NodeFrmID = "ND" + node.NodeID;
                node.Update();
                

                //更新表单类型.
                var frmID = "ND" + node.NodeID;
                var mapData = new Entity("BP.Sys.MapData", frmID);
                mapData.FrmType = FormType.FoolTruck;
                mapData.Update();
            }

            //执行流程检查.
            var flow = new Entity("BP.WF.Flow", flowNo);
            flow.DoMethodReturnString("DoCheck");

            alert('设置成功.');
            window.location.href = window.location.href;
        }
    </script>
</head>
<body >

<div id="bar"> </div>
<fieldset>
    <legend>说明</legend>
    <ul>
        <li>该表单是傻瓜表单的一种变形展现方式.</li>
        <li>也叫轨迹表单模式,为软通动力定制的一种表单展示类型.</li>
        <li>适合一个节点一个表单模式,简洁流畅，容易追踪历史运动过程.</li>
         <li><a href="javascript:DFoolFrm()">设计傻瓜表单</a> - <a href="javascript:SetAllNodeFrmUseThisSln()">设置该流程所有的节点都采用此表单方案</a></li>
     </ul>
</fieldset>

<fieldset>
    <legend>当前表单权限控制方案</legend>

    <div id="sln"></div>
    
</fieldset>



<fieldset>
<legend>说明</legend>
<ul>
  <li>该表单是以傻瓜表单展示，也叫累加表单，也叫轨迹表单。</li>
  <li>每个节点上都有自己的一个字段集合, 当前节点的表单是以前表单按照走过的顺序累加（默认字段只读）加上当前节点表单拼接而成的。</li>
  <li>该表单设计简单，思路清晰，适用于在审核组件模式下不能解决的审核节点特殊字段数据的采集。</li>
  <li>该表单是审核组件模式表单的有益补充。</li>


  <li><img src='../Img/Col4Frm.JPG' style="width:70%;"  /> </li>
</ul>
</fieldset>

</body>
</html>
